package com.joysuch.wwyt.streampusher;

import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author jiahao
 * @date 2020/7/30 18
 */
public abstract class JsAbstractRedisPublisher<T> implements JsPublisher<T> {

    @Autowired
    private RedissonClient redissonClient;


    private String topic;

    protected RedissonClient getRedissonClient() {
        return redissonClient;
    }

    public JsAbstractRedisPublisher(String topic) {
        this.topic = topic;
    }

    @Override
    public void publish(T t) {
        redissonClient.getTopic(this.topic).publish(t);
    }

}

